package com.htudata.item.dao;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;

import com.htudata.item.mapper.ItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ItemDao {
  @Autowired
  private ItemMapper itemMapper;
  
  public List<Map<String, Object>> selectItemKinds() {
    return this.itemMapper.selectItemKinds(null);
  }
  
  public JSONArray selectItemInfos() {
    return this.itemMapper.selectItemInfos(null);
  }
  
  public JSONArray selectNodesAndFlowsByItemId(List<Object> idList) {
    JSONObject params = new JSONObject();
    params.put("idList", idList);
    return this.itemMapper.selectNodesAndFlowsByItemId(params);
  }
  
  public JSONArray selectShowedItemsByFlowId(String flowId) {
    JSONObject params = new JSONObject();
    params.put("flowId", flowId);
    return this.itemMapper.selectShowedItemsByFlowId(params);
  }
  
  public JSONArray selectShowedLocalItemsByFlowId(String flowId, long userId, long getNodeOfUser) {
    JSONObject params = new JSONObject();
    params.put("flowId", flowId);
    params.put("userId", Long.valueOf(userId));
    params.put("getNodeOfUser", Long.valueOf(getNodeOfUser));
    return this.itemMapper.selectShowedLocalItemsByFlowId(params);
  }
  
  public JSONArray selectItems(String flowId, String nodeId, int isItemShowed, List<Long> userIds, List<Long> userIds2) {
    JSONObject params = new JSONObject();
    params.put("flowId", flowId);
    params.put("nodeId", nodeId);
    params.put("isItemShowed", Integer.valueOf(isItemShowed));
    params.put("userIds", userIds);
    params.put("userIds2", userIds2);
    return this.itemMapper.selectItems(params);
  }
  
  public JSONArray selectItemsAndNodes(String flowId, String nodeId, int isItemShowed) {
    JSONObject params = new JSONObject();
    params.put("flowId", flowId);
    params.put("nodeId", nodeId);
    params.put("isItemShowed", Integer.valueOf(isItemShowed));
    return this.itemMapper.selectItemsAndNodes(params);
  }
  
  public JSONArray selectShowItemsByFlowId(String flowId, long userId) {
    return this.itemMapper.selectShowItemsByFlowId(flowId, userId);
  }
  
  public JSONArray selectShowItemsByNodeId(String nodeId, long userId) {
    return this.itemMapper.selectShowItemsByNodeId(nodeId, userId);
  }
  
  public void updateShowOrHideItems(String nodeId, int isShowed) {
    this.itemMapper.updateShowOrHideItems(nodeId, isShowed);
  }
  
  public void insertHidedItemNode(String nodeId, long userId) {
    this.itemMapper.insertHidedItemNode(nodeId, userId);
  }
  
  public void deleteHidedItemNode(String nodeId, long userId) {
    this.itemMapper.deleteHidedItemNode(nodeId, userId);
  }
  
  public void batchInsertFlowShowedItems(String flowId, List<Long> itemIdList, long userId) {
    this.itemMapper.batchInsertFlowShowedItems(flowId, itemIdList, userId);
  }
  
  public void deleteFlowShowedItemsByFlowId(String flowId, long userId) {
    this.itemMapper.deleteFlowShowedItemsByFlowId(flowId, userId);
  }
  
  public void batchInsertNodeShowedItems(String nodeId, List<Long> itemIdList, long userId) {
    this.itemMapper.batchInsertNodeShowedItems(nodeId, itemIdList, userId);
  }
  
  public void deleteNodeShowedItemsByNodeId(String nodeId, long userId) {
    this.itemMapper.deleteNodeShowedItemsByNodeId(nodeId, userId);
  }
  
  public void batchInsertFlowHiddenItems(String flowId, List<Long> itemIdList, long userId) {
    this.itemMapper.batchInsertFlowHiddenItems(flowId, itemIdList, userId);
  }
  
  public void deleteFlowHiddenItemsByFlowId(String flowId, long userId) {
    this.itemMapper.deleteFlowHiddenItemsByFlowId(flowId, userId);
  }
}
